﻿<%@ Page Title="" Language="C#" MasterPageFile="~/resumemanager/resume.master" Inherits="WebManager.BasePage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Import Namespace="TalentPools.Model" %>
<%@ Import Namespace="TalentPools.BLL" %>
<script runat="server">

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Person_BaseMeans basemean = new Person_BaseMeans();
        basemean.name = txtrealname.Text.Trim();
        basemean.birthday = Convert.ToDateTime(txtbirthday.Text.Trim());
        basemean.sex = rblsex.SelectedValue;
        basemean.username = username;
        basemean.marriage = ddlmarriagestate.SelectedValue;
        basemean.card = txtidcard.Text.Trim();
        basemean.politicsStatus = ddlzzmianmao.SelectedValue;
        basemean.HKPlace = txthlplace.Text.Trim();
        basemean.city = txtcurrentcity.Text.Trim();
        basemean.currentAddress = txtaddress.Text.Trim();
        basemean.zipCode = txtyzbm.Text.Trim();
        basemean.cellphone = txtmobile.Text.Trim();
        basemean.phoneCode = txttellphone.Text.Trim();
        basemean.email = txtemail.Text.Trim();
        basemean.homePage = txtpage.Text.Trim();
        if (new Person_BaseMeansManager().InsertBaseMean(basemean))
        {

            lblbasemean.Text = "添加成功";
        }
        else
        {
            lblbasemean.Text = "添加失败";
        }
    }
    string username;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!MyUserLogin())
        {
            JsWindows("Cookie过期，请重新登录", "../Index.aspx");
            return;
        }

        username = Server.UrlDecode(Request.Cookies["User"].Values["name"]);
        if (new Person_BaseMeansManager().GetBeanMeanCount(username) > 0)
        {//更新操作
            RegP.Visible = false;
            EditP.Visible = true;
            Person_BaseMeans basemean = new Person_BaseMeansManager().GetBaseMean(username);
            txteditname.Text = basemean.name;
            rbleditsex.SelectedValue = basemean.sex;
            txteditbir.Text = basemean.birthday.ToShortDateString();
            ddleditmar.SelectedValue = basemean.marriage;
            txteditcard.Text = basemean.card;
            ddleditpoli.SelectedValue = basemean.politicsStatus;
            txtedithk.Text = basemean.HKPlace;
            txteditcity.Text = basemean.city;
            txteditaddress.Text = basemean.currentAddress;
            txtedityzbm.Text = basemean.zipCode;
            txtedittell.Text = basemean.phoneCode;
            txteditmobile.Text = basemean.cellphone;
            txteditemial.Text = basemean.email;
            txteditpage.Text = basemean.homePage;
        }
        else
        {//插入操作
            RegP.Visible = true;
            EditP.Visible = false;
        }
        if (!IsPostBack)
        {
            this.txtbirthday.Attributes.Add("ReadOnly", "true");
            this.txteditbir.Attributes.Add("ReadOnly", "true");
            ddleditmar.DataSource = new baseConfigManager().getconfigInfo("婚姻状态");

            ddleditmar.DataTextField = "value";
            ddleditmar.DataValueField = "value";
            ddleditmar.DataBind();

            ddlmarriagestate.DataSource = new baseConfigManager().getconfigInfo("婚姻状态");

            ddlmarriagestate.DataTextField = "value";
            ddlmarriagestate.DataValueField = "value";
            ddlmarriagestate.DataBind();

            ddleditpoli.DataSource = new baseConfigManager().getconfigInfo("政治面貌");
            ddleditpoli.DataTextField = "value";
            ddleditpoli.DataValueField = "value";
            ddleditpoli.DataBind();

            ddlzzmianmao.DataSource = new baseConfigManager().getconfigInfo("政治面貌");
            ddlzzmianmao.DataTextField = "value";
            ddlzzmianmao.DataValueField = "value";
            ddlzzmianmao.DataBind();

        }
    }

    protected void btnsubmit_edit_Click(object sender, EventArgs e)
    {
        Person_BaseMeans basemean = new Person_BaseMeans();
        basemean.name = txteditname.Text.Trim();
        basemean.birthday = Convert.ToDateTime(txteditbir.Text.Trim());
        basemean.sex = rbleditsex.SelectedItem.Value;
        basemean.sex = rbleditsex.SelectedValue;
        basemean.username = username;
        basemean.marriage = ddleditmar.SelectedValue;
        basemean.card = txteditcard.Text.Trim();
        basemean.politicsStatus = ddleditpoli.SelectedValue;
        basemean.HKPlace = txtedithk.Text.Trim();
        basemean.city = txteditcity.Text.Trim();
        basemean.currentAddress = txteditaddress.Text.Trim();
        basemean.zipCode = txtedityzbm.Text.Trim();
        basemean.cellphone = txteditmobile.Text.Trim();
        basemean.phoneCode = txtedittell.Text.Trim();
        basemean.email = txteditemial.Text.Trim();
        basemean.homePage = txteditpage.Text.Trim();
        if (new Person_BaseMeansManager().UpdateBaseMean(basemean))
        {
            Label1.Text = "修改成功";
        }
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server">
    </asp:ScriptManager>
    <asp:Panel ID="RegP" runat="server" Visible="true">
        <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>完 善 基 本 资 料</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>姓名：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtrealname" runat="server"></asp:TextBox><span class="style4"><asp:RequiredFieldValidator
                        ID="RequiredFieldValidator2" ControlToValidate="txtrealname" runat="server" ErrorMessage="请填写姓名"></asp:RequiredFieldValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        性别：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:RadioButtonList ID="rblsex" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                        <asp:ListItem Value="男" Text="男" Selected="True"></asp:ListItem>
                        <asp:ListItem Value="女" Text="女"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        出生日期：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtbirthday" runat="server" Width="150px"></asp:TextBox>
                    <asp:CalendarExtender TargetControlID="txtbirthday" ID="CalendarExtender2" runat="server">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            婚姻状态：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddlmarriagestate" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            身份证号：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtidcard" runat="server" MaxLength="20"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ControlToValidate="txtidcard"
                            runat="server" ErrorMessage="身份证格式不正确" ValidationExpression="\d{17}[\d|X]|\d{15}"></asp:RegularExpressionValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            政治面貌：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddlzzmianmao" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            户口所在地：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txthlplace" runat="server" MaxLength="50"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            现居住城市：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtcurrentcity" runat="server" MaxLength="50"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        邮政编码：</div>
                </td>
                <td width="77%" class="tdbg2">
                    <asp:TextBox ID="txtyzbm" runat="server"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="邮政编码格式不正确"
                            ControlToValidate="txtyzbm" ValidationExpression="\d{6}"></asp:RegularExpressionValidator>
                    </span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        手机号码：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtmobile" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        固话：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txttellphone" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4"></span>电子邮箱：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ControlToValidate="txtemail" ID="RegularExpressionValidator1"
                            runat="server" ErrorMessage="邮箱格式不正确" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        联系地址：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtaddress" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        个人主页：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtpage" runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnSubmit" runat="server" Text="提 交" OnClick="btnSubmit_Click" />&nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="lblbasemean" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="EditP" runat="server" Visible="true">
        <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>修 改 基 本 资 料</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>姓名：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txteditname" runat="server"></asp:TextBox><span class="style4"><asp:RequiredFieldValidator
                        ID="RequiredFieldValidator1" ControlToValidate="txteditname" runat="server" ErrorMessage="请填写姓名"></asp:RequiredFieldValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        性别：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:RadioButtonList ID="rbleditsex" runat="server" RepeatDirection="Horizontal"
                        RepeatLayout="Flow" AutoPostBack="True">
                        <asp:ListItem Value="男" Text="男"></asp:ListItem>
                        <asp:ListItem Value="女" Text="女"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class='tdbg'>12213312
                <td class="tdbg1">
                    <div align="right">
                        出生日期：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txteditbir" runat="server" Width="150px"></asp:TextBox>
                    <asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txteditbir" runat="server">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            婚姻状态：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddleditmar" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            身份证号：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txteditcard" runat="server" MaxLength="20"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" ControlToValidate="txteditcard"
                            runat="server" ErrorMessage="身份证格式不正确" ValidationExpression="\d{17}[\d|X]|\d{15}"></asp:RegularExpressionValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            政治面貌：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddleditpoli" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            户口所在地：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtedithk" runat="server" MaxLength="50"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            现居住城市：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txteditcity" runat="server" MaxLength="50"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        邮政编码：</div>
                </td>
                <td width="77%" class="tdbg2">
                    <asp:TextBox ID="txtedityzbm" runat="server"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server" ErrorMessage="邮政编码格式不正确"
                            ControlToValidate="txtedityzbm" ValidationExpression="\d{6}"></asp:RegularExpressionValidator>
                    </span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        手机号码：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txteditmobile" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        固话：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtedittell" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4"></span>电子邮箱：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txteditemial" runat="server"></asp:TextBox>
                    <span class="style4">
                        <asp:RegularExpressionValidator ControlToValidate="txtemail" ID="RegularExpressionValidator9"
                            runat="server" ErrorMessage="邮箱格式不正确" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        联系地址：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txteditaddress" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        个人主页：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txteditpage" runat="server"></asp:TextBox>
                    <span class="style4"></span>
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnsubmit_edit" runat="server" Text="提 交" OnClick="btnsubmit_edit_Click" />&nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
